package com.luocj.brvah_srl.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.luocj.brvah_srl.R;
import com.luocj.brvah_srl.evnet.MyEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Created by Administrator on 2018/1/22/022.
 */

public class FragmentB extends BaseFragment {
    private String TAG = FragmentB.class.getSimpleName();
    private FragmentA fragmentA = new FragmentA();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_b, container, false);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.i(TAG, "onResume: " + "-------->b");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        Log.i(TAG, "onDestroy: " + "------->>>bbb");
    }

    @Override
    protected void loadData() {
        Log.i(TAG, "loadData: " + "load ---------------------b");
        fragmentA.setOnButtonClickListener(new FragmentA.onButtonClickListener() {
            @Override
            public void onClick() {
                Log.i(TAG, "onClick: " + "ouhuo");
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessage(MyEvent event) {
        Log.i(TAG, "onEventGet:  " + event.toString());
    }
}
